module.exports = (appInfo) => {
  const config = (exports = {});
  config.keys = appInfo.name + "_1716018479649_7834";
  // 中间介
  config.middleware = ["errorHandler", "auth"];
  const userConfig = {};
  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
    // 跨域白名单
    domainWhiteList: ["http://localhost:3000"],
  };
  config.auth = {
    // auth的白名单
    ignore: ["/reg", "/login", "/ws", "/ceshi"],
  };
  // 允许跨域的方法
  config.cors = {
    origin: "*",
    allowMethods: "GET, PUT, POST, DELETE, PATCH",
  };
  exports.eslint = {
    enable: false, // 设置为 false 来禁用 ESLint
    package: "egg-eslint",
  };
  // 数据库配置
  config.sequelize = {
    dialect: "mysql",
    host: "127.0.0.1",
    username: "root",
    password: "123456",
    port: 3306,
    database: "boyi",
    // 中国时区
    timezone: "+08:00",
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at
      timestamps: true,
      // 字段生成软删除时间戳 deleted_at
      // paranoid: true,
      createdAt: "created_at",
      updatedAt: "updated_at",
      deletedAt: "deleted_at",
      // 所有驼峰命名格式化
      underscored: true,
    },
  };

  config.valparams = {
    // 参数验证
    locale: "zh-cn",
    throwError: true,
  };
  config.crypto = {
    // 加密
    secret: "coder_LT",
  };
  exports.jwt = {
    // 登录鉴权
    secret: "coder_LT",
  };
  config.redis = {
    // redis存储
    client: {
      port: 6379, // Redis port
      host: "127.0.0.1", // Redis host
      password: "123456",
      db: 2,
    },
  };

  config.cluster = {
    listen: {
      path: "",
      port: 7001,
      hostname: "0.0.0.0",
    },
  };

  config.multipart = {
    // oss处理文件类型
    mode: "file",
  };

  // oss存储 腾讯云
  config.oss = {
    client: {
      accessKeyId: "LTAI5tLFPUQeCxpf7EeBphXM",
      accessKeySecret: "fXYCC7dz8939WWaHMykYSfOuNevdWm",
      bucket: "boyi-coder",
      endpoint: "oss-cn-hangzhou.aliyuncs.com",
      timeout: "60s",
    },
  };
  return {
    ...config,
    ...userConfig,
  };
};
